﻿using Architecture.Api.Application.Commands.DeepProcessingCommand;
using Architecture.Api.Application.Commands.SupplierCommand;
using Architecture.Domain.TraceabilityManage;
using Architecture.Domian.DTO;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace Architecture.Api.Controllers
{
    /// <summary>
    /// 深加工API接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class DeepProcessingController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public DeepProcessingController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 深加工添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddDeepProcessing(DeepProcessingCreateCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 深加工公司添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddCorporation(DeepProcessingCorporationCraeteCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 公司图片添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> BatchCorporationPicList(DeepProcessingCorporationBatchPicListCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 食品安全信息添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> BatchDeepProcessingPicList(DeepProcessingBatchPicListCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 深加工公司显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Corporation> GetCorporationInfo([FromQuery] DeepProcessingCorporationQueryCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 公司图片显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PictureDTO>> GetCorporationPicture([FromQuery] DeepProcessingCorporationQueryPicListCommand command)
        {
            return await _mediator.Send(command);
        }


        /// <summary>
        /// 深加工显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<DeepProcessing> GetDeepProcessingInfo([FromQuery] DeepProcessingQueryCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 食品安全信息显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PictureDTO>> GetDeepProcessingPicture([FromQuery] DeepProcessingQueryPicListCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 深加工公司修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateCorporation(DeepProcessingCorporationUpdateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 深加工修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateDeepProcessing(DeepProcessingUpdateCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 批量操作供应商信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> BatchSupplier(SupplierBatchCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 供应商信息显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PictureListDTO>> GetSupplierPicture([FromQuery] SupplierQueryCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
